import request from '@/axios'
import type {UserLoginType, UserType} from './types'


export const loginApi = (data: UserLoginType): Promise<IResponse<UserType>> => {
    return request.post({url: '/sys/uc/login/byPwd', data})
}

export const loginOutApi = (): Promise<IResponse> => {
    return request.post({url: '/sys/uc/logout'})
}

export const getUserMenusApi = (): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
    return request.get({url: '/sys/menu/getUserMenuTree'})
}

export const getTestRoleApi = (): Promise<IResponse<AppCustomRouteRecordRaw[]>> => {
    return new Promise(resolve => {
        let data = [
            {
                path: '/dashboard',
                component: '#',
                redirect: '/dashboard/analysis',
                name: 'Dashboard',
                meta: {
                    title: 'router.dashboard',
                    icon: 'ant-design:dashboard-filled',
                    alwaysShow: true
                },
                children: [
                    {
                        path: 'analysis',
                        component: 'views/Dashboard/Analysis',
                        name: 'Analysis',
                        meta: {
                            title: 'router.analysis',
                            noCache: true,
                            affix: true
                        }
                    }
                ]
            },
            {
                path: '/components',
                component: '#',
                redirect: '/components/form/default-form',
                name: 'ComponentsDemo',
                meta: {
                    title: 'router.component',
                    icon: 'bx:bxs-component',
                    alwaysShow: true
                },
                children: [
                    {
                        path: 'form',
                        component: '##',
                        name: 'Form',
                        meta: {
                            title: 'router.form',
                            alwaysShow: true
                        },
                        children: [
                            {
                                path: 'default-form',
                                component: 'views/Components/Form/DefaultForm',
                                name: 'DefaultForm',
                                meta: {
                                    title: 'router.defaultForm'
                                }
                            },
                            {
                                path: 'use-form',
                                component: 'views/Components/Form/UseFormDemo',
                                name: 'UseForm',
                                meta: {
                                    title: 'UseForm'
                                }
                            }
                        ]
                    },
                    {
                        path: 'table',
                        component: '##',
                        redirect: '/components/table/default-table',
                        name: 'TableDemo',
                        meta: {
                            title: 'router.table',
                            alwaysShow: true
                        },
                        children: [
                            {
                                path: 'default-table',
                                component: 'views/Components/Table/DefaultTable',
                                name: 'DefaultTable',
                                meta: {
                                    title: 'router.defaultTable'
                                }
                            },
                            {
                                path: 'use-table',
                                component: 'views/Components/Table/UseTableDemo',
                                name: 'UseTable',
                                meta: {
                                    title: 'UseTable'
                                }
                            },
                            {
                                path: 'tree-table',
                                component: 'views/Components/Table/TreeTable',
                                name: 'TreeTable',
                                meta: {
                                    title: 'TreeTable'
                                }
                            },
                            {
                                path: 'table-image-preview',
                                component: 'views/Components/Table/TableImagePreview',
                                name: 'TableImagePreview',
                                meta: {
                                    title: 'router.PicturePreview'
                                }
                            },
                            {
                                path: 'table-video-preview',
                                component: 'views/Components/Table/TableVideoPreview',
                                name: 'TableVideoPreview',
                                meta: {
                                    title: 'router.tableVideoPreview'
                                }
                            },
                            {
                                path: 'card-table',
                                component: 'views/Components/Table/CardTable',
                                name: 'CardTable',
                                meta: {
                                    title: 'router.cardTable'
                                }
                            }
                            // {
                            //   path: 'ref-table',
                            //   component: 'views/Components/Table/RefTable',
                            //   name: 'RefTable',
                            //   meta: {
                            //     title: 'RefTable'
                            //   }
                            // }
                        ]
                    },
                    {
                        path: 'editor-demo',
                        component: '##',
                        redirect: '/components/editor-demo/editor',
                        name: 'EditorDemo',
                        meta: {
                            title: 'router.editor',
                            alwaysShow: true
                        },
                        children: [
                            {
                                path: 'editor',
                                component: 'views/Components/Editor/Editor',
                                name: 'Editor',
                                meta: {
                                    title: 'router.richText'
                                }
                            },
                            {
                                path: 'json-editor',
                                component: 'views/Components/Editor/JsonEditor',
                                name: 'JsonEditor',
                                meta: {
                                    title: 'router.jsonEditor'
                                }
                            }
                        ]
                    },
                    {
                        path: 'search',
                        component: 'views/Components/Search',
                        name: 'Search',
                        meta: {
                            title: 'router.search'
                        }
                    },
                    {
                        path: 'descriptions',
                        component: 'views/Components/Descriptions',
                        name: 'Descriptions',
                        meta: {
                            title: 'router.descriptions'
                        }
                    },
                    {
                        path: 'image-viewer',
                        component: 'views/Components/ImageViewer',
                        name: 'ImageViewer',
                        meta: {
                            title: 'router.imageViewer'
                        }
                    },
                    {
                        path: 'dialog',
                        component: 'views/Components/Dialog',
                        name: 'Dialog',
                        meta: {
                            title: 'router.dialog'
                        }
                    },
                    {
                        path: 'icon',
                        component: 'views/Components/Icon',
                        name: 'Icon',
                        meta: {
                            title: 'router.icon'
                        }
                    },
                    {
                        path: 'icon-picker',
                        component: 'views/Components/IconPicker',
                        name: 'IconPicker',
                        meta: {
                            title: 'router.iconPicker'
                        }
                    },
                    {
                        path: 'echart',
                        component: 'views/Components/Echart',
                        name: 'Echart',
                        meta: {
                            title: 'router.echart'
                        }
                    },
                    {
                        path: 'count-to',
                        component: 'views/Components/CountTo',
                        name: 'CountTo',
                        meta: {
                            title: 'router.countTo'
                        }
                    },
                    {
                        path: 'qrcode',
                        component: 'views/Components/Qrcode',
                        name: 'Qrcode',
                        meta: {
                            title: 'router.qrcode'
                        }
                    },
                    {
                        path: 'highlight',
                        component: 'views/Components/Highlight',
                        name: 'Highlight',
                        meta: {
                            title: 'router.highlight'
                        }
                    },
                    {
                        path: 'infotip',
                        component: 'views/Components/Infotip',
                        name: 'Infotip',
                        meta: {
                            title: 'router.infotip'
                        }
                    },
                    {
                        path: 'input-password',
                        component: 'views/Components/InputPassword',
                        name: 'InputPassword',
                        meta: {
                            title: 'router.inputPassword'
                        }
                    },
                    {
                        path: 'waterfall',
                        component: 'views/Components/Waterfall',
                        name: 'Waterfall',
                        meta: {
                            title: 'router.waterfall'
                        }
                    },
                    {
                        path: 'image-cropping',
                        component: 'views/Components/ImageCropping',
                        name: 'ImageCropping',
                        meta: {
                            title: 'router.imageCropping'
                        }
                    },
                    {
                        path: 'video-player',
                        component: 'views/Components/VideoPlayer',
                        name: 'VideoPlayer',
                        meta: {
                            title: 'router.videoPlayer'
                        }
                    }
                ]
            },
            {
                path: '/authorization',
                component: '#',
                redirect: '/authorization/user',
                name: 'Authorization',
                meta: {
                    title: 'router.authorization',
                    icon: 'eos-icons:role-binding',
                    alwaysShow: true
                },
                children: [
                    {
                        path: 'department',
                        component: 'views/Authorization/Department/Department',
                        name: 'Department',
                        meta: {
                            title: 'router.department'
                        }
                    },
                    {
                        path: 'user',
                        component: 'views/Authorization/User/User',
                        name: 'User',
                        meta: {
                            title: 'router.user'
                        }
                    },
                    {
                        path: 'menu',
                        component: 'views/Authorization/Menu/Menu',
                        name: 'Menu',
                        meta: {
                            title: 'router.menuManagement'
                        }
                    },
                    {
                        path: 'role',
                        component: 'views/Authorization/Role/Role',
                        name: 'Role',
                        meta: {
                            title: 'router.role'
                        }
                    }
                ]
            }
        ]
        resolve({data: data})
    })
}
